package com.winit.openapi.ups.controller;

import com.alibaba.fastjson.JSON;
import com.winit.common.spi.context.CommandContext;
import com.winit.openapi.controller.BaseController;
import com.winit.openapi.model.RequestMsg;
import com.winit.openapi.model.ResponseMsg;
import com.winit.ups.spi.calendar.CalendarService;
import com.winit.ups.spi.calendar.command.QueryCalendarIsNotBussinessDayCommand;
import com.winit.ups.spi.systemrule.command.CarrierQueryCommand;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping(value = "/ups/calendar")
public class UpsCalendarController extends BaseController {
    @Resource
    private CalendarService calendarService;


    @RequestMapping(value = "/queryCalendarIsNotBussinessDay")
    public String queryCalendarIsNotBussinessDay(@ModelAttribute RequestMsg requestMsg, @ModelAttribute ResponseMsg responseMsg) {
        QueryCalendarIsNotBussinessDayCommand command = JSON.parseObject(requestMsg.getData().toString(),QueryCalendarIsNotBussinessDayCommand.class);
        command.setCtx(CommandContext.getContext());
        String isNotBussinessDay = calendarService.queryCalendarIsNotBussinessDay(command);
        Map<String,Object> map = new HashMap<String, Object>();
        map.put("isNotBussinessDay", isNotBussinessDay);
        responseMsg.setData(map);
        return SUCCESS;
    }
}
